import { ApiProperty } from '@nestjs/swagger';
import { BeforeInsert, BeforeUpdate, Column, Entity } from 'typeorm';
import { BaseEntity } from './Base.Entity';
import { hashSync } from 'bcryptjs';
@Entity()
export class User extends BaseEntity {
  @BeforeInsert()
  update() {
    this.userpass = hashSync(this.userpass);
  }

  @ApiProperty({ description: '用户名', example: '测试用户名' })
  @Column()
  username: string;

  @ApiProperty({ description: '密码', example: '长度不能大于10' })
  @Column({ select: false })
  userpass: string;
}
